package cn.south.campus.business.controller;

import cn.south.campus.business.model.req.GoodsCategoryReq;
import cn.south.campus.business.model.vo.GoodsCategoryVo;
import cn.south.campus.business.service.GoodsCategoryService;
import cn.south.campus.common.model.bo.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 二手商品分类表 前端控制器
 * </p>
 *
 * @author chow
 * @since 2024-11-13
 */
@RestController
@RequestMapping("/campus/category")
@AllArgsConstructor
public class GoodsCategoryController {

    private final GoodsCategoryService goodsCategoryService;


    @GetMapping("list")
    public Result<List<GoodsCategoryVo>> list(){
        List<GoodsCategoryVo> list = goodsCategoryService.showFirst();
        return Result.success(list);
    }

    @GetMapping("tree")
    public Result<List<GoodsCategoryVo>> tree(GoodsCategoryReq req){
        List<GoodsCategoryVo> treeList = goodsCategoryService.tree(req);
        return Result.success(treeList);
    }

    @PutMapping("refresh")
    public Result<String> refresh(){
        goodsCategoryService.refresh();
        return Result.success("刷新成功");
    }

}
